<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
  <title>编程猫 web ide 前端性能测试</title>
  <style>
    body {
      font-family: sans-serif;
    }
    table {
      margin: auto;
    }
    tr {
      border: 1px solid grey;
    }
    h1 {
       text-align: center;
       margin: 30px auto 50px auto
    }
  </style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0.5">
  <h1>编程猫 web ide 前端性能测试</h1>
  <tr>
    <th>
      No.
    </th>
    <th>
      首次内容绘制时间(Firtst Contentful Paint)
    </th>
    <th>
      首次有效绘制时间(Firtst Meaningful Paint)
    </th>
    <th>
      首次 CPU 闲置时间(First CpuIdle)
    </th>
    <th>
      速度指数(Speed Index)
    </th>
    <th>
      可交互前的耗时(Time To Interactive)
    </th>
    <th>
      输入延迟(Estimated Input Latency)
    </th>
    <th >
      详细报告
    </th>
    <th style="text-align: left;width: 20px; word-break:break-all">
      网络参数
    </th>
  </tr>
  <tbody id="tableBody">
  </tbody>
</table>
<script>
// let timespent = %%TIME_SPENT%%;
// let timestamp = %%TIMESTAMP%%;
let summaryIndicator = %%SUMMARY_INDICATOR%%;
let tableBody = document.getElementById("tableBody");
let content = '';

for(let i=0; i < summaryIndicator.length; i++) {
  let reportName = summaryIndicator[i].reportName;
  let throttling = summaryIndicator[i].throttling;
  let indicator = summaryIndicator[i].indicator;

  content += `<tr style="border: 1px solid grey">
    <td>
      ${i+1}
    </td>
    <td>
      ${(indicator.firtstContentfulPaint/1000).toFixed(2)}s
    </td>
    <td>
      ${(indicator.firtstMeaningfulPaint/1000).toFixed(2)}s
    </td>
    <td>
      ${(indicator.firstCpuIdle/1000).toFixed(2)}s
    </td>
    <td>
      ${(indicator.speedIndex/1000).toFixed(2)}s
    </td>
    <td>
      ${(indicator.timeToInteractive/1000).toFixed(2)}s
    </td>
    <td>
      ${(indicator.estimatedInputLatency/1000).toFixed(2)}s
    </td>
    <td width="8px">
      <a href="${`../cases-report/${reportName}.html`}">查看</a>
    </td>
    <td with="30px" word-break="break-all">
      ${JSON.stringify(throttling)}
    </td>

  </tr>`
}
tableBody.innerHTML = content;
</script>
</body>
</html>
